package logic

import (
	"context"
	"src/models/mysql"

	"src/internal/svc"
	"src/src"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsShowLogic {
	return &GoodsShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsShowLogic) GoodsShow(in *src.GoodsShowRequest) (*src.GoodsShowResponse, error) {
	// todo: add your logic here and delete this line

	var show mysql.Good
	mysql.DB.Debug().Model(&show).Where("id = ?", in.Id).Find(&show)

	return &src.GoodsShowResponse{
		GoodTitle:   show.GoodTitle,
		GoodPrice:   int64(show.GoodPrice),
		GoodStock:   int64(show.GoodStock),
		GoodStatus:  int64(show.GoodStatus),
		LikeCollect: int64(show.LikeCollect),
	}, nil
}
